#科赫雪花
import turtle
import random


#一段
def dwline(n,size):#n阶，长度为size
    if n==0:
        turtle.fd(size)
    else:
        for angle in [0,60,-120,60]:
            turtle.left(angle)
            dwline(n-1,size/3)

#画一朵雪花
def dwflower(n,size):#n阶，长度为size
    for i in range(3):
        dwline(n,size)
        turtle.right(120)
    turtle.right(random.randint(0,360))
#画漫天雪花和颜色
def dwcolor(n):#x朵雪花，n阶
    x=random.randint(10,100)
    for i in range(x):
        size = random.randint(20, 100)
        color=['red','green','purple','blue','coral','pink']
        _x=random.randint(-(1366/2)+50,1366//2-50)
        _y=random.randint(-(768/2)+50,(768/2)-50)
        turtle.penup()
        turtle.goto(_x,_y)
        turtle.pendown()
        turtle.color(color[random.randint(0,5)],'#DCDCDC')
        turtle.begin_fill()
        # turtle.fillcolor()

        dwflower(n,size)
        turtle.end_fill()

#主程序
def main():
    turtle.hideturtle()
    turtle.setup(1366,768)
    turtle.speed(0)
    dwcolor(2)
    turtle.done()
main()